<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<!DOCTYPE html>
<html>
<head>
    <meta charset="UTF-8">
    <title>教师评教登录页面</title>
    <meta name="renderer" content="webkit|ie-comp|ie-stand">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width,user-scalable=yes, minimum-scale=0.4, initial-scale=0.8,target-densitydpi=low-dpi" />
    <meta http-equiv="Cache-Control" content="no-siteapp" />
    <link rel="stylesheet" href="./css/font.css">
    <link rel="stylesheet" href="./css/login.css">
    <link rel="stylesheet" href="./css/xadmin.css">
    <script type="text/javascript" src="https://cdn.bootcss.com/jquery/3.2.1/jquery.min.js"></script>
    <script src="./lib/layui/layui.js" charset="utf-8"></script>
    <!--[if lt IE 9]>
    <script src="https://cdn.staticfile.org/html5shiv/r29/html5.min.js"></script>
    <script src="https://cdn.staticfile.org/respond.js/1.4.2/respond.min.js"></script>
    <![endif]-->
</head>
<body class="login-bg" style="position: relative">
<div class="login layui-anim layui-anim-up" style="width: 90%;position: absolute;margin-top: 55px;margin-left: 470px">
    <div class="message">评教系统登录</div>
    <div id="darkbannerwrap"></div>
    
    <form style="margin-left: 0px;margin-top: 0px" method="post" class="layui-form" >
    	<select name="type">
            <option value="2">学生</option>
            <option value="1">老师</option>
            <option value="0">管理员</option>
        </select>
        <hr class="hr15">
        <input name="studentID" placeholder="学号"  type="text" lay-verify="required" class="layui-input" >
        <hr class="hr15"> 
        <input name="password" placeholder="密码"  type="password" lay-verify="required" class="layui-input" >
        <hr class="hr15">
        <hr class="hr15" style="height:15px">
        <input value="登录" lay-submit lay-filter="login" style="width:100%;" type="submit">
        <br><hr class="hr20" >
    </form>
</div>
 <script>
        $(function  () {
            layui.use('form', function(){
              var form = layui.form;
              //监听提交
              form.on('submit(login)', function(data){
            	  var url = "${pageContext.request.contextPath}/login_submit";
            	  var param = $(".layui-form").serialize();//表单序列化传递到后台
            	  $.post(url, param, function(data) {
            		if(data.flag==7){//返回7为管理员，跳转到adminIndex
            			location.href="${pageContext.request.contextPath}/adminIndex";
            		}else if(data.flag==8){//返回8为老师，跳转到teacherIndex
            			location.href="${pageContext.request.contextPath}/teacherIndex";
            		}else if(data.flag==9){//返回9为学生，跳转到studentIndex
            			location.href="${pageContext.request.contextPath}/studentIndex";
            		}else if(data.flag==1){
            			alert(data.msg);
      					location.reload();
            		}else if(data.flag==2){
            			alert(data.msg);
      					location.reload();
            		}else{
            			alert("登录失败，请从新登录！");
            			location.href="${pageContext.request.contextPath}/login";
            		}
            	  });
                return false;
              });
            });
        })
    </script>
</body>
</html>